package gz.gae.blog.util;

import com.google.appengine.api.images.Image;
import com.google.appengine.api.images.ImagesService;
import com.google.appengine.api.images.ImagesServiceFactory;
import com.google.appengine.api.images.Transform;

/**
 * Created by IntelliJ IDEA.
 * User: Kane
 * Date: 12/12/10
 * Time: 11:07 PM
 */
public class ImageUtil {
    public static byte[] resize(byte[] bytes, int widht, int height) {
        ImagesService imagesService = ImagesServiceFactory.getImagesService();
        Image image = ImagesServiceFactory.makeImage(bytes);
        Transform transform = ImagesServiceFactory.makeResize(widht, height);
        Image newImage = imagesService.applyTransform(transform, image);
        return newImage.getImageData();
    }
}
